home *** CD-ROM | disk | FTP | other *** search
/ Cocktail Hour / image.iso / TRIVIAEX.CST / 00001_Script_trivia procedures next >
Text File  |  1996-03-03  |  6KB  |  184 lines

  1. on hide toHide
  2.   set the visible of sprite toHide to FALSE
  3. end
  4.  
  5. on show toShow
  6.   set the visible of sprite toShow to TRUE
  7. end
  8.  
  9.  
  10.  
  11. ------------------------  general TRIVIA   -------------------------------------------------------------
  12. on yossi  triviaQuestMem, NumOfQuestions
  13.   global gTriviaQuestMem
  14.   global gNumOfQuestions
  15.   
  16.   repeat with i=13 to 17
  17.     show  i
  18.   end repeat
  19.   --  if the paramCount = 0 then
  20.   put "trivia base mat.1" into gTriviaQuestMem
  21.   put 40 into gNumOfQuestions
  22.   --  else 
  23.   put TriviaQuestMem into gTriviaQuestMem
  24.   put NumOfQuestions into gNumOfQuestions
  25.   --  end if
  26.   initTrivia  
  27.   showNextQuestion
  28. end 
  29.  
  30. on initTrivia 
  31.   set the scrolltop of member "trivia base mat.1.board"=0
  32.   
  33.   global gNumOfQuestions
  34.   global gQuestionsVec
  35.   global gRightAnswer
  36.   global gCluePointer
  37.   global  gTriviaQuestMem
  38.   global TriviaCounter
  39.   
  40.   set TriviaCounter=0
  41.   put [] into gQuestionsVec
  42.   repeat with i = 1 to gNumOfQuestions
  43.     --put i into item i of gQuestionsVec
  44.     add gQuestionsVec, i
  45.   end repeat
  46.   put 0 into field "score" of castLib "TriviaEx.cst"
  47.   
  48.   put empty into field "trivia base mat.1.board" of castLib "TriviaEx.cst"
  49.   put EMPTY into gRightAnswer
  50.   put EMPTY into gCluePointer
  51. end
  52.  
  53.  
  54. on showNextQuestion
  55.   global gQuestionsVec
  56.   global gRightAnswer
  57.   global gCluePointer
  58.   global  gTriviaQuestMem
  59.   global gNumOfQuestions
  60.   global TriviaCounter
  61.   
  62.   set TriviaCounter=TriviaCounter+1
  63.   --put random(the number of items of gQuestionsVec) into temp 
  64.   put random(count(gQuestionsVec)) into temp 
  65.   
  66.   --if QuestionToShow <> 0 then
  67.   if gQuestionsVec <> [] then
  68.     put value(getat(gQuestionsVec,temp)) into QuestionToShow
  69.     -- if TriviaCounter<41 then
  70.     --delete item temp of gQuestionsVec
  71.     deleteAt gQuestionsVec, temp
  72.     put item 1 of line QuestionToShow of field gTriviaQuestMem of castLib "TriviaEx.cst" into gRightAnswer
  73.     put item 2 of line QuestionToShow of field gTriviaQuestMem of castLib "TriviaEx.cst" into gCluePointer
  74.     
  75.     set the itemDelimiter to "@"
  76.     put gTriviaQuestMem&".Ques" into tempor
  77.     put gTriviaQuestMem&".Board" into screenFld
  78.     hide 10
  79.     put item QuestionToShow of the text of member tempor of castLib "TriviaEx.cst" into field screenFld of castLib "TriviaEx.cst"
  80.     if offset("d. ",item QuestionToShow of the text of member tempor of castLib "TriviaEx.cst")=0 then 
  81.       show 18
  82.     else
  83.       hide 18
  84.     end if
  85.     colorFld
  86.     show 10
  87.     set the itemDelimiter to ","
  88.   else
  89.     -- no more questions to be asked
  90.     put gTriviaQuestMem&".Board" into screenFld
  91.     put  " try again !! "&RETURN&" questions will repeat !!" into x
  92.     put x into field screenFld of castLib "TriviaEx.cst"
  93.     startTimer
  94.     repeat while the timer <= 3*60
  95.       nothing
  96.     end repeat
  97.     --    delay 3*60
  98.     initTrivia
  99.     --    put value(the last char of gTriviaQuestMem) into xxx
  100.     --    if  (the last char of gTriviaQuestMem) = 1 then initTrivia     
  101.     showNextQuestion
  102.   end if
  103. end 
  104.  
  105. on colorFld
  106.   global gTriviaQuestMem
  107.   
  108.   repeat with i =1 to the number of lines of field (gTriviaQuestMem&".Board")
  109.     case i of 
  110.       2,3: set the forecolor of line i of field (gTriviaQuestMem&".Board") to 71
  111.       4,5,6,7,8: set the forecolor of line i of field (gTriviaQuestMem&".Board") to 237
  112.     end case
  113.   end repeat
  114. end
  115.  
  116.  
  117.  
  118. on CheckAns userAns
  119.   global gQuestionsVec
  120.   global gTriviaQuestMem
  121.   global gRightAnswer
  122.   global gNumOfQuestions
  123.   global gCluePointer, gCurrentZone  -- boolean, after all.
  124.   
  125.   if not (the text of field "score" of castLib "TriviaEx.cst" = 10 and (the last char of gTriviaQuestMem) =1) then 
  126.     if  userAns= gRightAnswer then 
  127.       puppetSound "clink"
  128.       set the text of field "score" of castLib "TriviaEx.cst" to string(value(the text of field "score" of castLib "TriviaEx.cst")+1)
  129.       -- play sound right ans
  130.       
  131.       --
  132.       if the text of field "score" of castLib "TriviaEx.cst" = 10 and (the last char of gTriviaQuestMem) =1 then ----
  133.         
  134.         puppetSprite 19,1
  135.         global OnceCheck
  136.         set OnceCheck=0
  137.         go to marker ("triviaAnim")
  138.         
  139.         set the itemDelimiter to "@"
  140.         put gTriviaQuestMem&".Board" into screenFld
  141.         global Wins
  142.         set Wins=Wins+1
  143.         if Wins>3  then
  144.           put item random(3) of the text of member "triviaPrise" of castLib "TriviaEx.cst" into field screenFld of castLib "TriviaEx.cst"
  145.         else
  146.           
  147.           put item Wins of the text of member "triviaPrise" of castLib "TriviaEx.cst" into field screenFld of castLib "TriviaEx.cst"
  148.           
  149.         end if
  150.         --
  151.         global gTriviaQuestMem
  152.         if  the scrollTop of member  (gTriviaQuestMem&".Board")=0 then
  153.           repeat with i =1 to the number of lines of field (gTriviaQuestMem&".Board")
  154.             case i of 
  155.               1,2,3,11: set the forecolor of line i of field (gTriviaQuestMem&".Board") to 71
  156.                 --4,5,6,7,8,9,10,11,12: set the forecolor of line i of field (gTriviaQuestMem&".Board") to 237
  157.               otherwise  set the forecolor of line i of field (gTriviaQuestMem&".Board") to 237
  158.             end case
  159.           end repeat
  160.         end if
  161.         
  162.         --
  163.         set the visible of sprite 13=1
  164.         set the visible of sprite 14=1
  165.         set the itemDelimiter to ","
  166.         repeat with i=15 to 17
  167.           hide i
  168.         end repeat
  169.         set the visible of sprite 18=0
  170.         set the visible of sprite 21=1
  171.         set the visible of sprite 22=1
  172.         set the visible of sprite 23=1
  173.         set the visible of sprite 24=1
  174.         puppetSound 2,"yea"
  175.         --      showNextQuestion
  176.       else
  177.         showNextQuestion
  178.       end if
  179.     else
  180.       -- play sound wrong answer
  181.       showNextQuestion
  182.     end if
  183.   end if
  184. end